﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace BanHangCshap.Class.gkhtdl63.DAL
{
    public abstract class LoaiBoSanphamDAL:clsBaseDAL
    {
        /// <summary>
        /// Lấy danh sách điều kiện bảo hành
        /// </summary>
        /// <returns>Trả về một Datatable các điều kiện bảo hành</returns>
        public DataTable LoaiBoSanpham_LayDanhsach()
        {
            return base.Select("sp_LoaiBoSanpham_LayDanhsach");
        }

        public DataTable LoaiBoSanpham_LayTheoma(string xlMa)
        {
            string xlSPName = "sp_LoaiBoSanpham_LayTheoma";
            string[] xlSPPara = { "@Ma"};
            string[] xlSPValu = { xlMa};
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public bool LoaiBoSanpham_Them(DAL.Entities.LoaiBoSanpham xlLBSP)
        {
            string xlSPName = "sp_LoaiBoSanpham_Them";
            string[] xlSPPara = {   "@Ma"
                                    ,"@Ten"
                                    ,"@Mota"
                                    ,"@Ghichu"
                                };

            object xlGhichu = System.Data.SqlTypes.SqlString.Null;
            if (xlLBSP.Ghichu != null)
            {
                xlGhichu = xlLBSP.Ghichu;
            }

            object[] xlSPValu = {   xlLBSP.Ma
                                    ,xlLBSP.Ten
                                    ,xlLBSP.Mota
                                    ,xlGhichu
                                 };
            return base.Insert(xlSPName, xlSPPara, xlSPValu);
        }

        public bool LoaiBoSanpham_Capnhat(string xlMacu, DAL.Entities.LoaiBoSanpham xlLBSP)
        {
            string xlSPName = "sp_LoaiBoSanpham_Capnhat";
            string[] xlSPPara = {   "@Macu"
                                    ,"@Ma"
                                    ,"@Ten"
                                    ,"@Mota"
                                    ,"@Ghichu"
                                };

            object xlGhichu = System.Data.SqlTypes.SqlString.Null;
            if (xlLBSP.Ghichu != null)
            {
                xlGhichu = xlLBSP.Ghichu;
            }

            object[] xlSPValu = {   xlMacu
                                    ,xlLBSP.Ma
                                    ,xlLBSP.Ten
                                    ,xlLBSP.Mota
                                    ,xlGhichu
                                 };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }
    }
}
